﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Common.ParamInput;
using Admin.Core.Service.Quality;
using Admin.Core.Service.Quality.Input;
using Admin.Core.Service.Quality.MachineCheck.Input;
using Admin.Core.Service.TimingTask;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Quality
{
    public class MachineCheckController : AreaController
    {
        private readonly IMachineCheckService _machineCheckService;
        public MachineCheckController(IMachineCheckService machineCheckService, ITimingTaskService timingTaskService)
        {
            _machineCheckService = machineCheckService;
        }

        /// <summary>
        /// 查询单条校验信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _machineCheckService.GetAsync(id);
        }


        /// <summary>
        /// 查询分页校验信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<MachineCheckFilterInput> model)
        {
            return await _machineCheckService.PageAsync(model);
        }


        /// <summary>
        /// 查询单条校验报告信息 提交
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetCommit(long id)
        {
            return await _machineCheckService.GetCommitAsync(id);
        }

        
        /// <summary>
        /// 查询分页校验信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetOwnerPage(PageInput<ConmonFilterInput> model)
        {
            return await _machineCheckService.GetOwnerPageAsync(model);
        }



        /// <summary>
        /// 查询分页校验报告历史信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetCheckHisPage(PageInput<ConmonFilterIdInput> model)
        {
            return await _machineCheckService.GetCheckHisPageAsync(model);
        }


        /// <summary>
        /// 新增校验数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(MachineCheckAddInput input)
        {
            return await _machineCheckService.AddAsync(input);
        }

        /// <summary>
        /// 修改校验数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(MachineCheckUpdateInput input)
        {
            return await _machineCheckService.UpdateAsync(input);
        }


        /// <summary>
        /// 提交校验确认数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> UpdateCommit(CheckReportCommitInput input)
        {
            return await _machineCheckService.UpdateCommitAsync(input);
        }

        /// <summary>
        /// 删除校验数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _machineCheckService.SoftDeleteAsync(id);
        }

    }
}
